//
//  MYGActTableViewCell.swift
//  MYDoctor
//
//  Created by Mo on 2024/3/7.
//

import UIKit

class MYGActTableViewCell: UITableViewCell {
    lazy var numImageV:UIImageView = {
        let cont = UIImageView()
        cont.backgroundColor = RGBA(r: 209, g: 209, b: 209, a: 1)
        cont.layer.masksToBounds = true
        cont.layer.cornerRadius = 10.5
        return cont
    }()
    private lazy var docHeaderImageV:UIImageView = {
        let cont = UIImageView()
        cont.layer.masksToBounds = true
        cont.layer.cornerRadius = SCALEWIDTH(17.5)
        return cont
    }()
    private lazy var docNameLabel:UILabel = {
        let cont = UILabel()
        cont.textColor = RGBA(r: 51, g: 51, b: 51, a: 1)
        cont.font = UIFont.systemFont(ofSize: 15, weight: .medium)
        cont.text = "医生名字"
        return cont
    }()
    private lazy var docAddrLabel:UILabel = {
        let cont = UILabel()
        cont.textColor = RGBA(r: 102, g: 102, b: 102, a: 1)
        cont.font = UIFont.systemFont(ofSize: 12, weight: .regular)
        cont.text = "医院名字"
        return cont
    }()
    private lazy var hotNumLabel:UILabel = {
        let cont = UILabel()
        cont.textColor = RGBA(r: 51, g: 51, b: 51, a: 1)
        cont.font = UIFont.systemFont(ofSize: 13, weight: .regular)
        cont.text = ""
        return cont
    }()
    lazy var numberLabel:UILabel = {
        let cont = UILabel()
        cont.textColor = RGBA(r: 255, g: 255, b: 255, a: 1)
        cont.font = UIFont.systemFont(ofSize: 12, weight: .medium)
        cont.text = "1"
        return cont
    }()
    var dataModel:MYGActivesModel = MYGActivesModel(){
        didSet{
            docHeaderImageV.sd_setImage(with: URL(string: dataModel.avatar),placeholderImage: headPlaceholderImage)
            docNameLabel.text = dataModel.name
            docAddrLabel.text = dataModel.hospital
            hotNumLabel.text = dataModel.count
        }
    }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.backgroundColor = .white
        contentView.backgroundColor = .white

        self.contentView.addSubview(numImageV)
        numImageV.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(15))
            make.centerY.equalToSuperview()
            make.width.height.equalTo(SCALEWIDTH(21))
        }
        

        self.contentView.addSubview(docHeaderImageV)
        docHeaderImageV.snp.makeConstraints { make in
            make.left.equalTo(numImageV.snp.right).offset(SCALEWIDTH(15))
            make.centerY.equalToSuperview()
            make.width.height.equalTo(SCALEWIDTH(35))
        }
        

        self.contentView.addSubview(numberLabel)
        numberLabel.snp.makeConstraints { make in
            make.center.equalTo(numImageV)
        }

        self.contentView.addSubview(docNameLabel)
        docNameLabel.snp.makeConstraints { make in
            make.top.equalTo(docHeaderImageV.snp.top)
            make.left.equalTo(docHeaderImageV.snp.right).offset(SCALEWIDTH(18.5))
            make.height.equalTo(SCALEWIDTH(21))
        }

        self.contentView.addSubview(docAddrLabel)
        docAddrLabel.snp.makeConstraints { make in
            make.bottom.equalTo(docHeaderImageV.snp.bottom)
            make.left.equalTo(docHeaderImageV.snp.right).offset(SCALEWIDTH(18.5))
            make.height.equalTo(SCALEWIDTH(16.5))
        }

        self.contentView.addSubview(hotNumLabel)
        hotNumLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-SCALEWIDTH(25.5))
            make.height.equalTo(SCALEWIDTH(18.5))
        }
        
        let hotImageV = UIImageView()
        hotImageV.image = UIImage(named: "MYG_home_fire")
        self.contentView.addSubview(hotImageV)
        hotImageV.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalTo(hotNumLabel.snp.left).offset(-SCALEWIDTH(5))
            make.height.equalTo(SCALEWIDTH(9.5))
            make.width.equalTo(SCALEWIDTH(8))
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
